Skip to content

Introducing Caveat "Scopes"#51

Merged
hanzel98 merged 10 commits into
mainfrom
feat/scopes2
Aug 11, 2025
Merged

Introducing Caveat "Scopes"#51
hanzel98 merged 10 commits into
mainfrom
feat/scopes2

Conversation

@hanzel98

@hanzel98 hanzel98 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

📝 Description

Refactors the caveat builder architecture to support scoped configurations, and declarative Delegation configuration.

🔄 What Changed?

List the specific changes made:

  • Introduced "Scopes" to define a base Unit of Authority for a delegation
  • Updated createDelegation and createOpenDelegation to require a scope configuration (and Delegator Environment)

See https://www.notion.so/metamask-consensys/Scopes-22cf86d67d68801b93bdfb50416b789e for the different scopes, and permutations

🚀 Why?

Scopes: There is a significant risk that developers will (accidentally) create delegations with insufficient restrictions. Scopes reduce this likelihood, by ensuring all delegations start with a single unit of authority, that may be restricted further.

Declarative API: By defining the createDelegation and createOpenDelegation apis declaratively, it reduces the overhead for the developer to first create the caveat builder, then the delegation, they simply describe the delegation .

🧪 How to Test?

Describe how to test these changes:

  • Manual testing steps:
  1. Create a caveat builder using the new configuration-based API
  2. Test scope-based caveat building functionality
  3. Verify that existing caveat builder functionality still works with the new API
  • Automated tests added/updated
  • All existing tests pass

⚠️ Breaking Changes

List any breaking changes:

  • No breaking changes
  • Breaking changes (describe below):
    • createDelegation and createOpenDelegation now require an environment and scope, delegations without a scope must be manually created (intentional friction to create insecure delegations
    • resolveCaveats function signature updated to require environment and scope parameters
    • Some internal types and utility functions removed from public API

📋 Checklist

Check off completed items:

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

@hanzel98 hanzel98 requested a review from a team as a code owner August 7, 2025 02:35
@hanzel98 hanzel98 marked this pull request as draft August 7, 2025 02:35

@jeffsmale90 jeffsmale90 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great!

Comment thread packages/delegation-toolkit/src/caveatBuilder/scope/nativeTokenTransferScope.ts Outdated
Comment thread packages/delegation-toolkit/src/caveatBuilder/scope/nativeTokenTransferScope.ts Outdated
Comment thread packages/delegation-toolkit/src/caveatBuilder/scope/scopeTypes.ts Outdated
Comment thread packages/delegation-toolkit/src/caveatBuilder/scope/index.ts Outdated
@hanzel98 hanzel98 changed the title Feat/scopes2 Introducing Caveat "Scopes" Aug 7, 2025
@hanzel98 hanzel98 mentioned this pull request Aug 7, 2025
11 tasks
@hanzel98

hanzel98 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor Author

Old PR #31

jeffsmale90 and others added 6 commits August 7, 2025 17:35
- Add scope-based caveat builders for common delegation patterns
- Update delegation factory functions to require environment and scope configuration
- Move CoreCaveatBuilder into it's own file
- Move resolveCaveats into it's own file
B#	modified:   packages/delegator-e2e/test/caveats/exactExecutionBatch.test.ts
@hanzel98 hanzel98 marked this pull request as ready for review August 8, 2025 00:45
@cursor

cursor Bot commented Aug 8, 2025

Copy link
Copy Markdown

🚨 Bugbot Trial Expired

Your team's Bugbot trial has expired. Please contact your team administrator to turn on the paid plan to continue using Bugbot.

A team admin can activate the plan in the Cursor dashboard.

jeffsmale90
jeffsmale90 previously approved these changes Aug 8, 2025
@hanzel98 hanzel98 requested a review from jeffsmale90 August 8, 2025 20:44

@jeffsmale90 jeffsmale90 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hanzel98 hanzel98 merged commit 30542c3 into main Aug 11, 2025
17 checks passed
@hanzel98 hanzel98 deleted the feat/scopes2 branch August 11, 2025 14:35
@jeffsmale90 jeffsmale90 mentioned this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants